package com.own.business.sync.trigger.base.config;

import com.own.business.sync.trigger.base.property.SyncTriggerProperty;
import com.own.constant.ConstantCommon;
import lombok.NonNull;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

import java.util.Objects;

/**
 * SyncTriggerCondition
 *
 * @author chenxueli
 * @date 2024-01-08 16:46:00
 */
public class SyncTriggerCondition implements Condition {

    @Override
    public boolean matches(ConditionContext context, @NonNull AnnotatedTypeMetadata metadata) {
        return Objects.equals(context.getEnvironment().getProperty(SyncTriggerProperty.PREFIX + ".enable-save"), ConstantCommon.TRUE)
                || Objects.equals(context.getEnvironment().getProperty(SyncTriggerProperty.PREFIX + ".enableSave"), ConstantCommon.TRUE);
    }

}
